Home:ALL Converter>How to setup haproxy with docker swarm where haproxy is "outside" the overlay network?

How to setup haproxy with docker swarm where haproxy is "outside" the overlay network?

Ask Time:2022-04-03T17:35:34         Author:Saurabh Nanda

Json Formatter

I'm trying to setup a docker based system with the least amount of network abstraction/virtualization possible. This is why I avoided k8s and am trying docker-swarm instead.

I'd like haproxy to be started directly via systemd and listen to external traffic on ports 80/443 directly, i.e. without docker coming into the picture. However, when proxying traffing to backend servers, I'd like it to connect to docker-swarm services running in dnsrr mode.

How do I set this up? I've read this blog post multiple times, but in all three configurations it seems that haproxy itself is running as a docker-swarm service. I do not want any network "abstraction" to come between haproxy and customer-facing traffic.

Is a setup like this possible?

PS: A related question might be, how do I communicate between the host and a docker-swarm container running on the same host? I tried pinging 10.0.6.75 (the container's IP address) on the same host on which it was running, but it didn't work. Do I need to create some network route, or make some entry in iptables to get this to work?

Author:Saurabh Nanda,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/71724658/how-to-setup-haproxy-with-docker-swarm-where-haproxy-is-outside-the-overlay-ne
yy